#!/usr/bin/lua -f
s=arg[0] while strsub(s,-1)~="/" do s=strsub(s,1,-2) end dofile(s.."common.lua")
function bad()
	_ALERT("\nERROR IN LOGIN\n")
	execute("sleep 2")
	exit(-1)
end
readfrom("/etc/passwd")
while 1 do
	B=read()
	if not B then break end
	if strsub(B,1,strlen(arg[2]))==arg[2] then
		P=strsub(B,strfind(B,":")+1)
		P=strsub(P,1,strfind(P,":")-1)
		S=strsub(B,strfindlast(B,":")+1,-1)
		break
	end
end
readfrom()
if P=="ea416ed0759d46a8de58f63a59077499" then
print("\n The default \"root\" password is \"xxxx\",")
print(" edit /etc/passwd to change it, or edit")
print(" settings.s to change it permanently...\n")
end
write("Password: ")
execute("necho")
R=read()
readfrom("|echo -n "..R.."|md5sum")
X=strsub(read(),1,32)
execute("yecho")
if X=="*" then bad() end
if X==P then
execute("ile "..S.." -c \". /etc/profile\" -si")
else bad() end
exit(0)
